﻿CREATE TABLE [dbo].[arhOrdonantari] (
    [NrDoc]            DECIMAL (18)    NOT NULL,
    [DataDoc]          DATETIME        NOT NULL,
    [IDFurnizor]       BIGINT          NOT NULL,
    [ValoareLei]       DECIMAL (20, 2) NOT NULL,
    [IDJurnal]         INT             NOT NULL,
    [Scop]             VARCHAR (100)   NOT NULL,
    [DocJust]          VARCHAR (50)    NOT NULL,
    [AngLegal]         VARCHAR (50)    NOT NULL,
    [Achitat]          BIT             NOT NULL,
    [IdOrdonantare]    INT             NOT NULL,
    [CodUnitate]       SMALLINT        DEFAULT ((0)) NOT NULL,
    [IdModPlata]       INT             DEFAULT ((1)) NOT NULL,
    [TotalDatorat]     DECIMAL (18, 2) DEFAULT ((0)) NOT NULL,
    [TotalAvansuri]    DECIMAL (18, 2) DEFAULT ((0)) NOT NULL,
    [ArtAl]            VARCHAR (40)    DEFAULT ('') NOT NULL,
    [VizatCFP]         BIT             NOT NULL,
    [MotivRefuz]       VARCHAR (250)   DEFAULT ('') NOT NULL,
    [IDResponsabil]    INT             DEFAULT ((0)) NOT NULL,
    [DataVizaCFP]      DATETIME        DEFAULT (getdate()) NOT NULL,
    [NrRegCFP]         VARCHAR (20)    DEFAULT ('FARA') NOT NULL,
    [IBANSursa]        VARCHAR (24)    NULL,
    [IBANDest]         VARCHAR (24)    NULL,
    [IDDocumentPlata]  INT             NULL,
    [An]               SMALLINT        DEFAULT ((0)) NOT NULL,
    [IDSursaFinantare] SMALLINT        NULL,
    CONSTRAINT [PK_arhOrdonantari] PRIMARY KEY CLUSTERED ([IdOrdonantare] ASC),
    CONSTRAINT [FK_arhOrdonantari_arhArticoleAliniate] FOREIGN KEY ([ArtAl], [CodUnitate], [An]) REFERENCES [dbo].[arhArticoleAliniate] ([ArtAl], [CodUnitate], [An]),
    CONSTRAINT [FK_arhOrdonantari_Jurnale] FOREIGN KEY ([IDJurnal]) REFERENCES [dbo].[Jurnale] ([IDJurnal]),
    CONSTRAINT [FK_arhOrdonantari_ModPlata] FOREIGN KEY ([IdModPlata]) REFERENCES [dbo].[ModPlata] ([IDModPlata]),
    CONSTRAINT [FK_arhOrdonantari_Parteneri] FOREIGN KEY ([IDFurnizor]) REFERENCES [dbo].[Parteneri] ([IDPartener]),
    CONSTRAINT [FK_arhOrdonantari_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

